package com.lishe.lishe.lishe.module.mall.presenter;

import android.app.Activity;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Adapter;
import android.widget.Toast;

import com.lishe.lishe.lishe.base.BaseActivity;
import com.lishe.lishe.lishe.common.Globals;
import com.lishe.lishe.lishe.module.auth.activity.AuthActivity;
import com.lishe.lishe.lishe.module.commonclass.SearchActivity;
import com.lishe.lishe.lishe.module.commonclass.WebActivity;
import com.lishe.lishe.lishe.module.giftnote.activity.GiftNoteActivity;
import com.lishe.lishe.lishe.module.mall.activity.ClassificationActivity;
import com.lishe.lishe.lishe.module.mall.activity.ClassificationMallActivity;
import com.lishe.lishe.lishe.module.mall.activity.MallGoodsActivity;
import com.lishe.lishe.lishe.module.mall.activity.MallSearchActivity;
import com.lishe.lishe.lishe.module.mall.bean.MallGoods;
import com.lishe.lishe.lishe.module.mall.bean.MallItemObject;
import com.lishe.lishe.lishe.module.me.activity.MyAccountActivity;
import com.lishe.lishe.lishe.module.myorder.activity.MyOrdersActivity;
import com.lishe.lishe.lishe.module.recharge.activity.RechargeIntegralActivity;

/**
 * Created by shino on 2017/11/9.
 * 上层首页-所有adpater的itemt事件处理器（除了banner）
 */

public class MallMainAdapterPresenter {

    /**
     * 首页大推荐的活动
     * mallItemObject
     */
    public static void titleItemOnClick(Activity activity, MallItemObject mallItemObject) {
        if (mallItemObject.getValue() != null) {//原生
            if (mallItemObject.getOpen().trim().equals("商品")) {
                MallGoodsActivity.jump(activity, mallItemObject.getValue());
            } else if (mallItemObject.getOpen().trim().equals("分类")) {
                ClassificationMallActivity.jump(activity, mallItemObject.getValue(), null, false);
            } else if (mallItemObject.getOpen().trim().equals("购物")) {

            } else if (mallItemObject.getOpen().trim().equals("采集")) {

            } else if (mallItemObject.getOpen().trim().equals("其他")) {

            }
        } else {//H5
            WebActivity.jump(activity, mallItemObject.getLink_url());
        }
    }

    /**
     * 导航分类
     *
     * @param mallItemObject
     */
    public static void classifyItemOnClick(Activity activity, MallItemObject mallItemObject) {
        if (mallItemObject.getOpen() != null && mallItemObject.getOpen().trim().equals("商品分类")) {
            ClassificationActivity.jump(activity);
        } else if (mallItemObject.getOpen() != null && mallItemObject.getOpen().trim().equals("充值中心")) {
            if (!TextUtils.isEmpty(Globals.getToken())) {
                RechargeIntegralActivity.jump(activity);
            } else {
                AuthActivity.jump(activity);
            }
        } else if (mallItemObject.getOpen() != null && mallItemObject.getOpen().trim().equals("精选福利")) {
            GiftNoteActivity.jump(activity);
        } else if (mallItemObject.getOpen() != null && mallItemObject.getOpen().trim().equals("我的订单")) {
            if (!TextUtils.isEmpty(Globals.getToken())) {
                MyOrdersActivity.jump(activity, Globals.ORDER_TYPE_ALL);
            } else {
                AuthActivity.jump(activity);
            }
        } else if (mallItemObject.getOpen() != null && mallItemObject.getOpen().trim().equals("我的积分")) {
            if (!TextUtils.isEmpty(Globals.getToken())) {
                MyAccountActivity.jump(activity);
            } else {
                AuthActivity.jump(activity);
            }
        } else if (mallItemObject.getName().equals("精选福利")) {
            Toast.makeText(activity, "敬请期待！", Toast.LENGTH_SHORT).show();
        } else {
            WebActivity.jump(activity, mallItemObject.getLink_url());
        }

    }

    /**
     * 超值专区
     *
     * @param mallItemObject
     */
    public static void valuseItemOnClick(Activity activity, MallItemObject mallItemObject) {
        if (mallItemObject.getValue() != null) {//原生
            if (mallItemObject.getOpen().trim().equals("商品")) {
                MallGoodsActivity.jump(activity, mallItemObject.getValue());
            } else if (mallItemObject.getOpen().trim().equals("分类")) {
                ClassificationMallActivity.jump(activity, mallItemObject.getValue(), null, false);
            } else if (mallItemObject.getOpen().trim().equals("购物")) {

            } else if (mallItemObject.getOpen().trim().equals("采集")) {

            } else if (mallItemObject.getOpen().trim().equals("搜索")) {
                MallSearchActivity.jump(activity, mallItemObject.getValue());
            } else if (mallItemObject.getOpen().trim().equals("其他")) {

            }
        } else {//H5
            WebActivity.jump(activity, mallItemObject.getLink_url());
        }
    }

    /**
     * 精选活动title
     *
     * @param mallItemObject
     */
    public static void activityTitleOnClick(Activity activity, MallItemObject mallItemObject) {
        if (mallItemObject.getValue() != null) {//原生
            if (mallItemObject.getOpen().trim().equals("商品")) {
                MallGoodsActivity.jump(activity, mallItemObject.getValue());
            } else if (mallItemObject.getOpen().trim().equals("分类")) {
                ClassificationMallActivity.jump(activity, mallItemObject.getValue(), null, false);
            } else if (mallItemObject.getOpen().trim().equals("购物")) {

            } else if (mallItemObject.getOpen().trim().equals("采集")) {

            } else if (mallItemObject.getOpen().trim().equals("其他")) {

            }
        } else {//H5
            WebActivity.jump(activity, mallItemObject.getLink_url());
        }

    }

    /**
     * 精选活动滚动栏
     *
     * @param mallGoods
     */
    public static void activityItemOnClick(Activity activity, MallGoods mallGoods) {
        if (!mallGoods.getTitle().equals("more") && mallGoods.getPrice() != 0) {
            maybeLoveItemOnClick(activity, mallGoods);
        } else {//查看更多
            ClassificationMallActivity.jump(activity, mallGoods.getItem_id(), null, true);
        }
    }

    /**
     * 猜你喜欢
     *
     * @param mallGoods 商品对象
     */
    public static void maybeLoveItemOnClick(Activity activity, MallGoods mallGoods) {
        Log.e("猜你喜欢", mallGoods.getTitle());
        MallGoodsActivity.jump(activity, mallGoods.getItem_id());
    }
}
